import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:patient_flutter/common/category_card.dart';
import 'package:patient_flutter/common/custom_ui.dart';
import 'package:patient_flutter/common/dashboard_top_bar_title.dart';
import 'package:patient_flutter/common/top_bar_area.dart';
import 'package:patient_flutter/generated/l10n.dart';
import 'package:patient_flutter/screen/specialists_detail_screen/specialists_detail_screen.dart';
import 'package:patient_flutter/screen/specialists_screen/specialists_screen_controller.dart';

class SpecialistsScreen extends StatelessWidget {
  final int screenType;

  const SpecialistsScreen({Key? key, required this.screenType}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final controller = SpecialistsScreenController();
    return Scaffold(
      body: Column(
        children: [
          screenType == 0
              ? DashboardTopBarTitle(title: S.current.specialists)
              : TopBarArea(title: S.current.specialists),
          GetBuilder(
            init: controller,
            builder: (_) {
              return Expanded(
                child: controller.isLoading && controller.categories.isEmpty
                    ? CustomUi.loaderWidget()
                    : controller.categories.isEmpty
                        ? CustomUi.noData()
                        : GridView.builder(
                            itemCount: controller.categories.length,
                            padding: const EdgeInsets.all(7),
                            gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                              crossAxisCount: 2,
                              childAspectRatio: 1.7,
                            ),
                            itemBuilder: (context, index) {
                              return CategoryCard(
                                categories: controller.categories[index],
                                onTap: () {
                                  Get.to(
                                    () => const SpecialistsDetailScreen(),
                                    arguments: controller.categories[index],
                                  );
                                },
                              );
                            },
                          ),
              );
            },
          ),
        ],
      ),
    );
  }
}
